containter: Remove gtk_container_get_path_for_child()
authorBenjamin Otte <otte@redhat.com>
Tue, 21 Jan 2020 01:59:26 +0000 (02:59 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 21 Jan 2020 11:47:16 +0000 (12:47 +0100)
docs/reference/gtk/gtk4-sections.txt
gtk/gtkbox.c
gtk/gtkcontainer.c
gtk/gtkcontainer.h
gtk/gtkwidget.c

index de0ec777ddfc31fd971909d5d4a30a303bd9ba68..c36a4a2b549d5a1403f3797ea402ebe2ea7a3580 100644 (file)
@@ -775,7 +775,6 @@ gtk_container_add
 gtk_container_remove
 gtk_container_foreach
 gtk_container_get_children
-gtk_container_get_path_for_child
 gtk_container_get_focus_vadjustment
 gtk_container_set_focus_vadjustment
 gtk_container_get_focus_hadjustment
index f6195dbfbbf1ffbd86a7935d096dacb62f1bc800..800e31847fafd28168d23dfe2f96fb11c0751017 100644 (file)
@@ -109,9 +109,6 @@ static void gtk_box_forall             (GtkContainer   *container,
                                         GtkCallback     callback,
                                         gpointer        callback_data);
 static GType gtk_box_child_type        (GtkContainer   *container);
-static GtkWidgetPath * gtk_box_get_path_for_child
-                                       (GtkContainer   *container,
-                                        GtkWidget      *child);
 
 G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER,
                          G_ADD_PRIVATE (GtkBox)
@@ -131,7 +128,6 @@ gtk_box_class_init (GtkBoxClass *class)
   container_class->remove = gtk_box_remove;
   container_class->forall = gtk_box_forall;
   container_class->child_type = gtk_box_child_type;
-  container_class->get_path_for_child = gtk_box_get_path_for_child;
 
   g_object_class_override_property (object_class,
                                     PROP_ORIENTATION,
@@ -242,105 +238,6 @@ gtk_box_child_type (GtkContainer   *container)
   return GTK_TYPE_WIDGET;
 }
 
-typedef struct _CountingData CountingData;
-struct _CountingData {
-  GtkWidget *widget;
-  gboolean found;
-  guint before;
-  guint after;
-};
-
-static void
-count_widget_position (GtkWidget *widget,
-                       gpointer   data)
-{
-  CountingData *count = data;
-
-  if (!_gtk_widget_get_visible (widget))
-    return;
-
-  if (count->widget == widget)
-    count->found = TRUE;
-  else if (count->found)
-    count->after++;
-  else
-    count->before++;
-}
-
-static gint
-gtk_box_get_visible_position (GtkBox    *box,
-                              GtkWidget *child)
-{
-  CountingData count = { child, FALSE, 0, 0 };
-  GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
-
-  /* foreach iterates in visible order */
-  gtk_container_foreach (GTK_CONTAINER (box),
-                         count_widget_position,
-                         &count);
-
-  /* the child wasn't found, it's likely an internal child of some
-   * subclass, return -1 to indicate that there is no sibling relation
-   * to the regular box children
-   */
-  if (!count.found)
-    return -1;
-
-  if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
-      gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
-    return count.after;
-  else
-    return count.before;
-}
-
-static GtkWidgetPath *
-gtk_box_get_path_for_child (GtkContainer *container,
-                            GtkWidget    *child)
-{
-  GtkWidgetPath *path, *sibling_path;
-  GtkBox *box = GTK_BOX (container);
-  GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
-  GList *list, *children;
-
-  path = _gtk_widget_create_path (GTK_WIDGET (container));
-
-  if (_gtk_widget_get_visible (child))
-    {
-      gint position;
-
-      sibling_path = gtk_widget_path_new ();
-
-      /* get_children works in visible order */
-      children = gtk_container_get_children (container);
-      if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
-          _gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
-        children = g_list_reverse (children);
-
-      for (list = children; list; list = list->next)
-        {
-          if (!_gtk_widget_get_visible (list->data))
-            continue;
-
-          gtk_widget_path_append_for_widget (sibling_path, list->data);
-        }
-
-      g_list_free (children);
-
-      position = gtk_box_get_visible_position (box, child);
-
-      if (position >= 0)
-        gtk_widget_path_append_with_siblings (path, sibling_path, position);
-      else
-        gtk_widget_path_append_for_widget (path, child);
-
-      gtk_widget_path_unref (sibling_path);
-    }
-  else
-    gtk_widget_path_append_for_widget (path, child);
-
-  return path;
-}
-
 static void
 gtk_box_init (GtkBox *box)
 {
index 71493d7ef350eca0617135c80deda1e5e18b91a9..3650f4ee972ca9ce0703fc73b99de0c822f7696e 100644 (file)
@@ -115,9 +115,6 @@ static void     gtk_container_children_callback    (GtkWidget         *widget,
                                                     gpointer           client_data);
 static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget   *widget);
 
-static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container,
-                                                              GtkWidget    *child);
-
 /* GtkBuildable */
 static void gtk_container_buildable_init           (GtkBuildableIface *iface);
 static GtkBuildableIface    *parent_buildable_iface;
@@ -149,7 +146,6 @@ gtk_container_class_init (GtkContainerClass *class)
   class->forall = NULL;
   class->set_focus_child = gtk_container_real_set_focus_child;
   class->child_type = NULL;
-  class->get_path_for_child = gtk_container_real_get_path_for_child;
 
   container_signals[ADD] =
     g_signal_new (I_("add"),
@@ -651,18 +647,6 @@ gtk_container_real_set_focus_child (GtkContainer *container,
     }
 }
 
-static GtkWidgetPath *
-gtk_container_real_get_path_for_child (GtkContainer *container,
-                                       GtkWidget    *child)
-{
-  GtkWidgetPath *path;
-
-  path = _gtk_widget_create_path (GTK_WIDGET (container));
-  gtk_widget_path_append_for_widget (path, child);
-
-  return path;
-}
-
 static void
 gtk_container_children_callback (GtkWidget *widget,
                                  gpointer   client_data)
@@ -783,35 +767,3 @@ gtk_container_get_focus_hadjustment (GtkContainer *container)
   return hadjustment;
 }
 
-/**
- * gtk_container_get_path_for_child:
- * @container: a #GtkContainer
- * @child: a child of @container
- *
- * Returns a newly created widget path representing all the widget hierarchy
- * from the toplevel down to and including @child.
- *
- * Returns: A newly created #GtkWidgetPath
- **/
-GtkWidgetPath *
-gtk_container_get_path_for_child (GtkContainer *container,
-                                  GtkWidget    *child)
-{
-  GtkWidgetPath *path;
-
-  g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
-  g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
-  g_return_val_if_fail (container == (GtkContainer *) _gtk_widget_get_parent (child), NULL);
-
-  path = GTK_CONTAINER_GET_CLASS (container)->get_path_for_child (container, child);
-  if (gtk_widget_path_get_object_type (path) != G_OBJECT_TYPE (child))
-    {
-      g_critical ("%s %p returned a widget path for type %s, but child is %s",
-                  G_OBJECT_TYPE_NAME (container),
-                  container,
-                  g_type_name (gtk_widget_path_get_object_type (path)),
-                  G_OBJECT_TYPE_NAME (child));
-    }
-
-  return path;
-}
index e3dd79a0ac5766a3140e741ca56c4302f1fc9356..332846df7fe72faa5212fb1fb5497579d161be64 100644 (file)
@@ -62,8 +62,6 @@ struct _GtkContainer
  * @child_type: Returns the type of the children supported by the container.
  * @set_child_property: Set a property on a child of container.
  * @get_child_property: Get a property from a child of container.
- * @get_path_for_child: Get path representing entire widget hierarchy
- *    from the toplevel down to and including @child.
  *
  * Base class for containers.
  */
@@ -83,8 +81,6 @@ struct _GtkContainerClass
   void    (*set_focus_child)   (GtkContainer    *container,
                                 GtkWidget       *child);
   GType   (*child_type)                (GtkContainer    *container);
-  GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
-                                         GtkWidget    *child);
 
 
   /*< private >*/
@@ -132,10 +128,6 @@ void    gtk_container_forall                    (GtkContainer *container,
                                              GtkCallback   callback,
                                              gpointer      callback_data);
 
-GDK_AVAILABLE_IN_ALL
-GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer      *container,
-                                                  GtkWidget         *child);
-
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)
 
 G_END_DECLS
index ccdf26d6d43bfedb500d5889052927f8970d613d..9f37c854f27f470eda85ba1bdd99a23aac6412d6 100644 (file)
@@ -6320,7 +6320,7 @@ reset_style_recurse (GtkWidget *widget, gpointer user_data)
  * Updates the style context of @widget and all descendants
  * by updating its widget path. #GtkContainers may want
  * to use this on a child when reordering it in a way that a different
- * style might apply to it. See also gtk_container_get_path_for_child().
+ * style might apply to it.
  */
 void
 gtk_widget_reset_style (GtkWidget *widget)
@@ -11247,9 +11247,7 @@ _gtk_widget_create_path (GtkWidget *widget)
 {
   GtkWidget *parent = _gtk_widget_get_parent (widget);
 
-  if (parent && GTK_IS_CONTAINER (parent))
-    return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
-  else if (parent)
+  if (parent)
     {
       GtkWidgetPath *path = _gtk_widget_create_path (parent);
       gtk_widget_path_append_for_widget (path, widget);